package packet.in;
 /*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import io.ByteReader;
import packet.RawPacket;
import packet.RtxInPacket;

/**
 * Project  : rtx
 * Author   : solosky < solosky772@qq.com >
 * Created  : 4/7/14
 * License  : Apache License 2.0
 */
public class NormalIMPacket  extends RtxInPacket{

    private int imId;
    private int unknown1;
    private String imType;
    private String imType2; //unknown
    private String from;
    private String to;
    private short unknown2;
    private String body;

    public NormalIMPacket(RawPacket rawPacket) {
        super(rawPacket);
    }

    @Override
    public void unpack(ByteReader reader) {
        imId = reader.readInt();
        reader.readInt(); //zero
        reader.readInt(); //zero
        unknown1 =reader.readInt();
        imType = reader.readUnicode();
        reader.readByte(); //zero
        imType2 = reader.readUnicode();
        from = reader.readUnicode();
        reader.readByte(); //zero
        to = reader.readUnicode();
        unknown2 = reader.readShort();     //unknown 01 01
        body = reader.readUnicode2();
    }

    public int getImId() {
        return imId;
    }

    public int getUnknown1() {
        return unknown1;
    }

    public String getImType() {
        return imType;
    }

    public String getImType2() {
        return imType2;
    }

    public String getFrom() {
        return from;
    }

    public String getTo() {
        return to;
    }

    public int getUnknown2() {
        return unknown2;
    }

    public String getBody() {
        return body;
    }

    @Override
    public String toString() {
        return "NormalIMPacket{" +
                "imId=" + imId +
                ", imType='" + imType + '\'' +
                ", imType2='" + imType2 + '\'' +
                ", from='" + from + '\'' +
                ", to='" + to + '\'' +
                ", body='" + body + '\'' +
                '}';
    }
}
